package com.example.evanproject.controller;

import com.example.evanproject.domain.Courselesson;
import com.example.evanproject.service.impl.CourselessonServiceImpl;
import com.example.evanproject.util.AjaxResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("lesson")
public class CourseLessonController {
    @Autowired
    private CourselessonServiceImpl courseLessonService;
    @RequestMapping("selectbyid")
    public AjaxResult selectbyid(Integer id){

        return AjaxResult.success(courseLessonService.selectbyid(id))  ;
    }

//    添加课时信息
    @RequestMapping("addcourselesson")

    /*传的参数为 moId(模块id) lsName(课时名)*/
    public AjaxResult addcourselesson(Courselesson courseLesson){
        return  AjaxResult.success(courseLessonService.addcourselesson(courseLesson));
    }

      /*添加课时信息(就是在课时的那个id 修改内容)*/
    /*这个是富文本的内容(了解文件后 再看看要不要写道一个接口里面)*/
    @PostMapping("addlessoninfo")
    public  AjaxResult addlessoninfo(@RequestBody Courselesson courselesson){

  return  AjaxResult.success(courseLessonService.addlessoninfo(courselesson.getLsId(),courselesson.getLsText()));
    }
    //   上传视频
    @PostMapping("updateviod")
    public  AjaxResult updateviod(@RequestParam("file") MultipartFile file,Integer lessonid,Integer type){
      return AjaxResult.success(courseLessonService.updateviod(file,lessonid,type));

    }



    /*查询某个节点是否有信息*/

    @RequestMapping("selectInfobyLessonId")
    public AjaxResult selectInfobyLessonId(Integer lessonId){
  Courselesson courselesson=courseLessonService.getById(lessonId);
  return AjaxResult.success(courselesson);
    }
}

